package Tools;

import java.io.IOException;
import java.io.PrintWriter;
import java.net.Socket;
import java.net.UnknownHostException;


public class ClientBouchon {
	private static String port = "5555";
	private static String host = "127.0.0.1";
	private static String xml;
	
	public static void main(String[] args){
		Socket sock = null;
		xml = "<methodCall>"+
		"<methodName>display</methodName>"+
		"<params>"+
		"<param>"+
		"<value>"+
		"<object oid=\"http://www.jm.fr/1000000\">"+
		"<fields>"+
		"<field name=\"x\"><value><double>10.0</double></value></field>"+
		"<field name=\"y\"><value><double>20.0</double></value></field>"+
		"<field name=\"mark\"><value><string>@</string></value></field>"+
		"</fields>"+
		"<methods>"+
		"<method language=\"Java\">"+
		"public String toString()"+
		"{"+
		"return this.x + this.mark + this.y ;"+
		"}"+
		"</method>"+
		"</methods>"+
		"</object>"+
		"</value>"+
		"</param>"+
		"</params>"+
		"</methodCall>";
		try {
			sock = new Socket(host, Integer.parseInt(port));
			sock.setReuseAddress(true);
			PrintWriter pw = new PrintWriter(sock.getOutputStream());
			pw.println(xml);
			pw.flush();
			pw.close();
			sock.close();
		} catch (NumberFormatException e) {
			e.printStackTrace();
		} catch (UnknownHostException e) {
			e.printStackTrace();
		} catch (IOException e) {
			e.printStackTrace();
		}
		System.err.println("[client: Done]"); 
	}
	
}
